//
//  WriteTextViewController.m
//  MyChatchat
//
//  Created by 小灰灰的pro on 16/3/29.
//  Copyright © 2016年 小灰灰. All rights reserved.
//

#import "WriteTextViewController.h"
#import "WriteText.h"
#import <AVOSCloud/AVOSCloud.h>
@interface WriteTextViewController ()
@property (nonatomic,strong)WriteText *writeView;
@end

@implementation WriteTextViewController

- (void)loadView{
    self.writeView = [[WriteText alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.view = self.writeView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.writeView.backgroundColor = [UIColor whiteColor];
    [self.writeView.leftButton addTarget:self action:@selector(leftButtonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.writeView.rightButton addTarget:self action:@selector(rightButtonAction) forControlEvents:UIControlEventTouchUpInside];
}

- (void)leftButtonAction{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)rightButtonAction{
    //设置点赞字段
    NSNumber *like = @0;
    AVObject *todoFolder = [[AVObject alloc] initWithClassName:@"TodoFolder"];// 构建对象
    [todoFolder setObject:self.writeView.textView.text forKey:@"context"];// 设置名称
    [todoFolder setObject:like forKey:@"like"];
    [todoFolder setObject:@0 forKey:@"priority"];// 设置优先级
    [todoFolder saveInBackground];// 保存到服务端
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
